Refactors to e2e test cases - #413
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Dependency ReviewThe following issues were found:
License Issuespackage-lock.json
package.json
OpenSSF ScorecardScorecard details
Scanned Files
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors e2e test infrastructure to improve maintainability and reduce hard-coded dependencies. The changes introduce dynamic path generation from a sitemap-based cache, centralize test utilities, and add site-level metadata generation.
Key changes:
- Created a dynamic path system using
.cache/pages.jsongenerated from sitemap data - Centralized e2e helper exports in a single index file
- Removed debug test file and hard-coded TEST_URLS references
- Added sitemap integration with robots.txt support
Reviewed Changes
Copilot reviewed 26 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/helpers/baseTest.ts | New extended Playwright test providing dynamic path fixtures from pages.json |
| test/e2e/helpers/index.ts | Centralized exports for e2e test helpers |
| test/e2e/specs/01-smoke/critical-paths.spec.ts | Replaced TEST_URLS with inline path strings and centralized imports |
| test/e2e/specs/01-smoke/site.spec.ts | New site-wide smoke tests for RSS, manifest, and 404 handling |
| test/e2e/specs/02-pages/*.spec.ts | Updated imports from console-errors to consoleErrors (8 files) |
| test/e2e/specs/debug-404s.spec.ts | Removed debug utility file |
| src/lib/config/sitemap-serialize.ts | New sitemap serializer that generates pages.json cache |
| astro.config.ts | Added sitemap integration and pages.json writer hook |
| src/pages/robots.txt.ts | New robots.txt API route |
| vitest.config.ts | Added test paths for new helper tests |
| package.json | Added @astrojs/sitemap dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| * ``` | ||
| */ | ||
| import { test as baseTest, expect } from '@playwright/test' | ||
| import pagesData from '../../../.cache/pages.json' with { type: 'json' } |
There was a problem hiding this comment.
The import path assumes .cache/pages.json exists at build time, but this file is generated during the Astro build process. If tests run before the first build, this import will fail. Consider adding error handling or documentation about running the build first, or dynamically check for the file's existence.
| import fixtureData from '@test/e2e/helpers/__fixtures__/pages.json' | ||
|
|
||
| // Mock the pages.json import | ||
| vi.mock('.cache/pages.json', () => ({ |
There was a problem hiding this comment.
The mock path '.cache/pages.json' is relative and doesn't match the actual import path '../../../.cache/pages.json' used in baseTest.ts. This mock will not intercept the import correctly. The path should be '../../../.cache/pages.json' or an absolute path from the project root.
| vi.mock('.cache/pages.json', () => ({ | |
| vi.mock('../../../.cache/pages.json', () => ({ |
| import type { SitemapItem } from '@astrojs/sitemap' | ||
|
|
||
| // Accumulator for pages data | ||
| const pagesData: Record<string, string[] | true> = {} |
There was a problem hiding this comment.
Using true as a sentinel value alongside string arrays makes the type union confusing. Consider using a more explicit structure like Record<string, { isSingle: boolean; slugs?: string[] }> or separate the single pages from multi-level pages into different data structures for better type safety.
| `) | ||
| }) | ||
|
|
||
| it('should extract all pages', () => { |
There was a problem hiding this comment.
Double space between 'all' and 'pages' should be a single space.
| it('should extract all pages', () => { | |
| it('should extract all pages', () => { |
Description
Type of Change
Changes Made
Related Issues
Closes #
Testing
npm run test:unit)npm run test:e2e:ready)npm run lint)npm run build)Screenshots (if applicable)
Checklist
Additional Notes